namespace Patterns4Net.Core.Patterns
{
    using Mono.Cecil;
    using Attributes.DesignPatterns;

    /// <summary>
    /// Represents the Adapter design pattern.
    /// </summary>
    [Immutable]
    public class Adapter : PatternBase, IWrapper
    {
        public Adapter(TypeDefinition adapterType, TypeReference target, TypeReference adaptee)
        {
            this.AdapterType = adapterType;
            this.TargetType = target;
            this.AdapteeType = adaptee;
        }

        public TypeDefinition AdapterType { get; private set; }

        public TypeReference AdapteeType { get; private set; }

        public TypeReference TargetType { get; private set; }

        #region IWrapper Members

        TypeReference IWrapper.WrappedType
        {
            get { return this.AdapteeType; }
        }

        TypeReference IWrapper.TargetInterface
        {
            get { return this.TargetType; }
        }

        TypeDefinition IWrapper.WrapperType
        {
            get { return this.AdapterType; }
        }

        #endregion
    }
}
